﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using CYTS.Aoyou.Framework.Config;
using System.Net;
using CYTS.Aoyou.Framework.Log;
using CYTS.Aoyou.Framework.Session;

namespace CYTS.Aoyou.Framework.Web
{
    [Obsolete]
    public abstract class MvcApplicationBase : System.Web.HttpApplication
    {
        [Obsolete]
        public MvcApplicationBase()
        {
            this.BeginRequest += new EventHandler(MvcApplicationBase_BeginRequest);
            this.EndRequest += new EventHandler(MvcApplicationBase_EndRequest);
        }

        [Obsolete]
        protected virtual void Application_Start()
        {

        }

        [Obsolete]
        protected virtual void Application_End(object sender, EventArgs e)
        {
            
        }

        [Obsolete]
        protected virtual void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();

            string url = Context.Request.Url == null ? string.Empty : Context.Request.Url.ToString();
            if (url.Length > 1000)
            {
                //URL控制在1000个字符以内
                url = url.Substring(0, 1000);
            }

            string refer = Context.Request.RawUrl != null ? Context.Request.RawUrl : string.Empty;
            if (refer.Length > 1000)
            {
                refer = refer.Substring(0, 1000);
            }

            WebLogger.LogError(Context.Request.UserHostAddress, url, refer, Guid.NewGuid().ToString(), Dns.GetHostName(), string.Empty, ex);

        }

        [Obsolete]
        protected virtual void MvcApplicationBase_BeginRequest(object sender, EventArgs e)
        {
            
        }

        [Obsolete]
        protected virtual void MvcApplicationBase_EndRequest(object sender, EventArgs e)
        {

        }

        [Obsolete]
        protected virtual void Session_Start(object sender, EventArgs e)
        {
            #region 初始化Session Cache

            SessionHelper.InitSession();  

            #endregion
        }

        [Obsolete]
        protected virtual void Session_End(object sender, EventArgs e)
        {

        }


    }
}
